package com.zpark.resume.controller;

import com.zpark.resume.common.ResponseResult;
import com.zpark.resume.common.StatusCode;
import com.zpark.resume.entity.Experience;
import com.zpark.resume.entity.Honor;
import com.zpark.resume.entity.Training;
import com.zpark.resume.service.IHonorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @PackageName: com.zpark.resume.controller
 * @ClassName: HonorController
 * @Description:
 * @author: RZS
 * @date: 2023/6/1  21:54
 */
@RestController
@RequestMapping("/honor")
@CrossOrigin
public class HonorController {

    @Autowired
    private IHonorService honorService;

    /**
     * 根据cv_id查询Honor数据
     * @param id cv_id
     * @return
     */
    @PostMapping("/find_by_cv_id/{id}")
    public ResponseResult<List<Honor>> findRecommendByCvId(@PathVariable("id") Integer id){
        // 调用业务层接口查询数据
        List<Honor> honors = honorService.findByCvId(id);
        return new ResponseResult<>(StatusCode.SUCCESS.getCode(), StatusCode.SUCCESS.getMessage(), honors);
    }

    /**
     * 添加荣誉经历
     * @param honor
     * @return
     */
    @PostMapping("/add")
    public ResponseResult<Void> addTra(@RequestBody Honor honor){
        // 调用业务层接口
        honorService.addHonor(honor);
        return new ResponseResult<>(StatusCode.SUCCESS.getCode(), StatusCode.SUCCESS.getMessage(), null);
    }

    /**
     * 修改荣誉经历
     * @param honor
     * @return
     */
    @PostMapping("/update")
    public ResponseResult<Void> changeTra(@RequestBody Honor honor){
        // 调用业务层接口
        honorService.changeHonorById(honor);
        return new ResponseResult<>(StatusCode.SUCCESS.getCode(), StatusCode.SUCCESS.getMessage(), null);
    }

    /**
     * 删除荣誉经历
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult<Void> removeTra(@PathVariable("id") Integer id){
        // 调用业务层接口
        honorService.removeHonorById(id);
        return new ResponseResult<>(StatusCode.SUCCESS.getCode(), StatusCode.SUCCESS.getMessage(), null);
    }
}
